473,419 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Image mouse-over with dropdown menu

I am trying to find if there is a way, using CSS/HTML, to code a simple single drop-down menu that is activated when you mouse-over an image. For example, in windows, you can right mouse click an icon on the desktop and get a drop down menu to appear. I would like to do the same thing on a website except without having to mouse click, so when you mouse over an image, the menu drops down.
Jul 23 '07 #1
3 5847
drhowarddrfine
7,435 Expert 4TB
There are some interesting css3 things that I've only touched on and am experimenting with when I find time. One uses :target to highlight another element and make other elements appear or not when hovering over another. I don't think it can make a drop down list appear but I haven't tried it either.

The downside to that is it only works in modern browsers and not IE. So the only alternative would be javascript.
Jul 23 '07 #2
Try the menu examples and tutorials at alistapart
Jul 24 '07 #3
tburger
58
I thought this looked interesting, so I tried to code something up quickly.

Here's what I got:

Test Image-Over Menu

If you open this in Firefox (the javascript is slightly different to work properly in IE6), you will see a picture of a guitar. If you mouse over the image, a menu will pop up - similar to the action of right clicking in windows...

The trick to this is something I picked up while learning about the Navigation Matrix approach to menu styling. We can essentially make an image act as a link by hiding the actual anchor <a> below it. This is done by making the height of the anchor 0, setting the anchor's background to a certain image, and then adjusting the anchor's upper padding.

Expand|Select|Wrap|Line Numbers
  1. a { 
  2. height: 0px;
  3. background-image: xx; 
  4. background-repeat:no-repeat;
  5. width: xx (where xx is width of picture);
  6. padding-top: xx (where xx is height of picture);
  7. overflow: hidden;
  8.  
This will make the actual link invisible to the user, but will have created a box that acts as a link around the image.

From there, I used a short script to hide/show the menu when moused over.

Feel free to check out the code:

JScript

CSS

Although I have since modified the script, thanks to Raphaël GOETTER
at alsacreations.com for the basic model...

Hope this helps, let me know if you have questions

Tom
Jul 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Wonko | last post by:
Here's my problem if anyone could be so kind to help me out. I assume it's quite easy for an experienced programmer but I'm not one of them :) I have a JavaScript code that: - displays multiple...
4
by: Csaba2000 | last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE 5.5+). This should work regardless of whether IE has focus. Normally you would...
5
by: Roger Shrubber | last post by:
I have a page with images that the user can drag from one frame to another. I need them to see a "ghost image" of the image they are dragging, while the original stays put. I use the onmousemove...
15
by: Tony Gahlinger | last post by:
I'm using my browser (Mozilla/5.0 Linux i686 Gecko/20031007 Firebird/0.7) to do some client-side image processing. I want to capture the sequence of coordinates a user clicks on in xxx.jpg in the...
4
by: Jay | last post by:
Hi, How can I capture mouse position on Image? I found number of script capturing mouse position of the page. But I could not find anything based on image. What I want to find out is X Y...
3
by: Dustin Carroll | last post by:
Hello, I am trying to capture a right mouse button click on an image. So far I am getting the left click with <body onload="document.getElementById('image').onclick=eventclick;"> <image...
9
by: Daniel N | last post by:
Is it possible to determine if the image under a mouse changes in VB.net code? For example if I position the mouse using the command; Windows.Forms.Cursor.Position = New System.Drawing.Point(680,...
3
by: peter.chase | last post by:
In my Web application, a have an image within a DIV. One of the allowed user gestures is to drag the image with the mouse. When dragging, parts of the image that would otherwise be displayed...
0
by: David | last post by:
On Sun, May 4, 2008 at 5:28 PM, Valerio Valerio <vdv100@gmail.comwrote: I assume what you want to do is allow the user to drag the mouse across your desktop, and your program, running in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.